<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?>
<?php
class Myuser_helper {

	 public function __construct(){
	      parent::__construct();
	 }//endfct
    function get_userid($email){
    	$CI = &get_instance();
    	$CI->load->model('recipients_model');
    	$userid = $CI->recipients_model->get_userid($email);
    	return $userid;
    }
	public function randLetterNumber(){
		$length = 8;
		$characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
		$string = '';
		for ($p = 0; $p < $length; $p++) {
			$string .= $characters[mt_rand(0, strlen($characters) - 1)];
		}
		return $string;
	}//end fct

    function getUserData(){
    	$CI = &get_instance();
	 	$CI->load->model('users_model');
		return $CI->users_model->get_user();
    }

    function getUserRecipients(){
    	return $this->recipients_model->getRecipients();
    }

	function getRecipients( $messageid ){
		$CI = &get_instance();
	 	$CI->load->model('recipients_model');
	 	return $CI->recipients_model->getMsgRecipients($messageid);
	}

	function countMsg($type='photos'){
		$CI = &get_instance();
		$CI->load->model('messages_model');
		return $CI->messages_model->countMessages($type);
	}

	function getFiles( $messageid ){
		$CI = &get_instance();
	 	$CI->db->where('messageid',$messageid);
	 	$files = $CI->db->get('mlme_messages_files_x');
	 	return $files->result();
	}

	// Gets random ads
	// @param string $section : sidebar; bottom
	// @param int limit
	function getAds($section='sidebar', $limit=2){
		$CI = &get_instance();
		$query = $CI->db->query("SELECT * FROM mlme_advertisements WHERE section = '".$section."' AND status = 1 ORDER BY rand() LIMIT $limit ");
		return $query->result();
	}


}/*eend of class*/
